package com.cheng.frame;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;
import org.dyno.visual.swing.layouts.GroupLayout;

import com.cheng.util.DataUtil;


public class PrivateCodePanel extends JPanel{
	private static final long serialVersionUID = 1L;
	private PrivateCodePanel privateCodePanel;
	private BufferedImage image;
	
	public PrivateCodePanel(){
		privateCodePanel = this;
		privateCodePanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED, null, null));
		privateCodePanel.setLayout(new GroupLayout());

	}
	
	public PrivateCodePanel getPanel() {
		if (privateCodePanel == null) {
			privateCodePanel = new PrivateCodePanel();
		}
		return privateCodePanel;
	}  
  
    @Override  
    public void paintComponent(Graphics g1) {  
    	if(DataUtil.instance().getpImage() != null){
    		int x = 0;  
    		int y = 0;  
    		Graphics g = (Graphics) g1;  
    		// 该方法会将图像加载到内存，从而拿到图像的详细信息。  
    		image = DataUtil.instance().getpImage();  
    		if (null == image) {  
    			System.out.println("error!!!");  
    		}  
    		
    		g.drawImage(image, x, y, image.getWidth(this), image.getHeight(this),  
    				this);  
    		g = null;  
    		
    	}
    }  
}
